/*-
 * Public platform independent Near Field Communication (NFC) library
 * 
 * Copyright (C) 2011, Romuald Conty
 * 
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */

#include <host/nfc.h>
#include <host/nfc-emulation.h>

void prepare_initiator_data(const nfc_modulation_t nm,
			    byte_t **ppbtInitiatorData,
			    size_t *pszInitiatorData)
{
	switch (nm.nmt) {
	case NMT_ISO14443B:
		/* Application Family Identifier (AFI) must equals 0x00 in
		 * order to wakeup all ISO14443-B PICCs
		 * (see ISO/IEC 14443-3)
		 */
		*ppbtInitiatorData = (byte_t *)"\x00";
		*pszInitiatorData = 1;
		break;
	case NMT_ISO14443BI:
		/* APGEN */
		*ppbtInitiatorData = (byte_t *)"\x01\x0b\x3f\x80";
		*pszInitiatorData = 4;
		break;
	case NMT_ISO14443B2SR:
		/* Get_UID */
		*ppbtInitiatorData = (byte_t *)"\x0b";
		*pszInitiatorData = 1;
		break;
	case NMT_ISO14443B2CT:
		/* SELECT-ALL */
		*ppbtInitiatorData = (byte_t *)"\x9F\xFF\xFF";
		*pszInitiatorData = 3;
		break;
	case NMT_FELICA:
		/* polling payload must be present
		 * (see ISO/IEC 18092 11.2.2.5)
		 */
		*ppbtInitiatorData = (byte_t *)"\x00\xff\xff\x01\x00";
		*pszInitiatorData = 5;
		break;
	default:
		*ppbtInitiatorData = NULL;
		*pszInitiatorData = 0;
		break;
	}
}
